package com.ajing.logextractor.filter;

import lombok.extern.slf4j.Slf4j;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

@Slf4j
public class RegexFilter extends AbstractFilter {

    private final Pattern pattern;

    public RegexFilter(String pattern, String match) {
        super(pattern, match);
        this.pattern = Pattern.compile(pattern);
    }

    @Override
    public boolean filter(String input) {
        Matcher matcher = pattern.matcher(input);
        return matcher.matches();
    }
}
